package com.huawei;


import java.util.*;

/**
 * Created by Z-hong on 2024/7/23.
 */

public class HJ67_hard {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int in[] = new int[4];
        for (int i = 0; i < 4; i++) {
            in[i] = sc.nextInt();
        }
        boolean[] flag = new boolean[4];
        System.out.println(get(flag,1,in,new HashSet<>()));
    }

    public static boolean get(boolean[] flag, int i, int []arr, Set<Integer> set){
        for (int j = 0; j < arr.length; j++) {
            Set<Integer> temp=new HashSet<>();
            temp.addAll(set);
            if(flag[j]) continue;
            if (i==1){
                temp.add(arr[j]);
            }else{
                if(set(arr[j],i,temp)) return true;
            }
            flag[j]=true;
            if(get(flag,i+1,arr,temp)) return true;
            flag[j]=false;
        }
        return false;
    }
    public static boolean set(int number,int i, Set<Integer> set){
        final Boolean[] res = {false};
        Set<Integer> temp=new HashSet<>();
        temp.addAll(set);
        //加
        for (Integer entry:temp){
            if(entry+number==24&&i==4) res[0] =true;
            set.add(entry+number);
        }
        //减
        for (Integer entry:temp){
            int num_1= entry-number;
            int num_2=number-entry;
            if((num_2==24||num_1==24)&&i==4) res[0] =true;
            set.add(num_1);
            set.add(num_2);
        }
        //乘
        for (Integer entry : temp){

            if(entry*number==24&&i==4) res[0] =true;
            set.add(entry*number);
        }

        //除
        for (Integer entry:temp){

            if(number==0)break;
            if (entry==0) continue;
            int key= entry;
            if(key%number==0){
                int num=key/number;
                if(num==24&&i==4) res[0] =true;
                set.add(num);
            }
            if(number%key==0){
                int num=number/key;
                if(num==24&&i==4) res[0] =true;
                set.add(num);
            }
        }
        return res[0];
    }
}
